import { IPSSysMsgTempl } from '../msg/ipssys-msg-templ';
import { IPSWFInteractiveLink } from './ipswfinteractive-link';
import { IPSWFLinkRole } from './ipswflink-role';
import { IPSWFProcessRole } from './ipswfprocess-role';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSWFLinkRoleImpl extends PSModelObjectImpl implements IPSWFLinkRole {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected pssysmsgtempl: IPSSysMsgTempl | null = null;

  getPSSysMsgTempl(): IPSSysMsgTempl | null {
    if (this.pssysmsgtempl != null) return this.pssysmsgtempl;
    const value = this.M.getPSSysMsgTempl;
    if (value == null) {
      return null;
    }
    this.pssysmsgtempl = this.getPSModel4('msg.IPSSysMsgTempl', value, 'getPSSysMsgTempl') as IPSSysMsgTempl;
    return this.pssysmsgtempl;
  }

  get psSysMsgTempl(): IPSSysMsgTempl | null {
    return this.getPSSysMsgTempl();
  }

  getPSSysMsgTemplMust(): IPSSysMsgTempl {
    const value = this.getPSSysMsgTempl();
    if (value == null) {
      throw new Error('未指定通知消息模板');
    }
    return value;
  }

  protected pswfprocessrole: IPSWFProcessRole | null = null;

  getPSWFProcessRole(): IPSWFProcessRole | null {
    if (this.pswfprocessrole != null) return this.pswfprocessrole;
    const value = this.M.getPSWFProcessRole;
    if (value == null) {
      return null;
    }
    const ipswfinteractivelink = this.getParentPSModelObject('wf.IPSWFInteractiveLink') as IPSWFInteractiveLink;
    if (ipswfinteractivelink != null) {
      this.pswfprocessrole = ipswfinteractivelink.getFromPSWFProcessMust().findPSWFProcessRole(value);
    }
    return this.pswfprocessrole;
  }

  get psWFProcessRole(): IPSWFProcessRole | null {
    return this.getPSWFProcessRole();
  }

  getPSWFProcessRoleMust(): IPSWFProcessRole {
    const value = this.getPSWFProcessRole();
    if (value == null) {
      throw new Error('未指定流程处理角色');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSWFLinkRoleImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'wf.IPSWFLinkRole') return true;
    return super.instanceof(cls);
  }
}
